import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import Vant from 'vant';
import 'vant/lib/index.css';
import "amfe-flexible";
import { Lazyload } from 'vant';
import './assets/font/iconfont/iconfont.css';

import {get, post} from "@/util/http";
Vue.prototype.$get = get;
Vue.prototype.$post = post;

Vue.config.productionTip = false;
Vue.use(Vant);
Vue.use(Lazyload, {
  lazyComponent: true,
});

// 替换网页标题
router.beforeEach((to, from, next) => {
  if(to.meta.title) {
    document.title = to.meta.title; 
  }
  next();
})


router.afterEach(() => {
  let bodySrcollTop = document.body.scrollTop
  if (bodySrcollTop !== 0) {
    document.body.scrollTop = 0
    return
  }
  let docSrcollTop = document.documentElement.scrollTop
  if (docSrcollTop !== 0) {
    document.documentElement.scrollTop = 0
  }
});

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount("#app");
